﻿using System.Windows;

namespace zaklad_rtv
{
    /// <summary>
    /// Interaction logic for ConfigForm.xaml
    /// </summary>
    public partial class ConfigForm
    {
        public MainWindow MainWindow { get; set; }

        public ConfigForm()
        {
            InitializeComponent();
            InitializeFields();
        }

        private void InitializeFields()
        {
            _tbConfigFooter.Text = MainWindow.DBHelper.GetConfig(StringConstants.ConfigFooterName).ConfigValue;
        }

        private void SaveForm(object sender, RoutedEventArgs e)
        {
            var configFooter = new Config
                {
                    ConfigName = StringConstants.ConfigFooterName,
                    ConfigDescription = StringConstants.ConfigFooterDesc,
                    ConfigValue = _tbConfigFooter.Text
                };
            MainWindow.DBHelper.Update(configFooter);
            MessageBox.Show("Ustawienia zapisane!", "Sukces", MessageBoxButton.OK,
                                    MessageBoxImage.Information);
        }

        private void About(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(StringConstants.Credits, "Informacje o programie", MessageBoxButton.OK,
                            MessageBoxImage.Information);
        }
    }
}
